import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screen_util.dart';
import 'package:flutter/material.dart';
import 'package:study_online/entity/Problem.dart';
import 'package:study_online/global/colors.dart';
import 'package:study_online/global/myIcons.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.black26,
          title: Text('container'),
        ),
        body: ProblemReplyItem(),
      ),
    );
  }
}

class ProblemReplyItem extends StatefulWidget {
  ProblemReplyItem({Key key,this.problem}) : super(key: key);
  Problem problem;
  @override
  _ProblemReplyItemState createState() {
    return _ProblemReplyItemState();
  }
}

class _ProblemReplyItemState extends State<ProblemReplyItem> {
  Problem _problem;
  @override
  void initState() {
    super.initState();
    _problem=widget.problem;
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(
      BoxConstraints(
          maxWidth: MediaQuery.of(context).size.width,
          maxHeight: MediaQuery.of(context).size.height),
      designSize: Size(1080, 2340),
    );
    return Container(
      width: ScreenUtil().screenWidth - ScreenUtil().setWidth(110),
      //height: ScreenUtil().setHeight(520),
      margin: EdgeInsets.only(top: ScreenUtil().setHeight(58)),
      child: Column(
        //mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              ClipOval(
                child: Image.network(
                    _problem.photo,
                    width: ScreenUtil().setSp(80),
                    height: ScreenUtil().setSp(80),
                    fit: BoxFit.cover),
              ),
              SizedBox(width: ScreenUtil().setWidth(13)),
              Text(
                _problem.name,
                style: TextStyle(
                  fontSize: ScreenUtil().setSp(46),
                  color: Colors.black,
                ),
              ),
              Expanded(
                child: Align(
                  alignment: Alignment.bottomRight,
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.end,
                    children: [
                      Text(
                        _problem.time,
                        style: TextStyle(
                          fontSize: ScreenUtil().setSp(35),
                          color: AppColors.subtext,
                        ),
                      ),
                    ],
                  ),
                ),
              )
            ],
          ),
          Container(
            margin: EdgeInsets.only(
                left: ScreenUtil().setWidth(98),
                top: ScreenUtil().setHeight(26)),
            child: Column(
              //mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Align(
                  child: Text(
                    _problem.content,
                    style: TextStyle(
                      fontSize: ScreenUtil().setSp(46),
                      color: Colors.black,
                    ),
                  ),
                  alignment: Alignment.bottomLeft,
                ),
                SizedBox(height: ScreenUtil().setHeight(5)),
                Row(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    Expanded(
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.end,
                        children: [
                          IconButton(
                              icon: Icon(
                                MyIcons.thumb_up_alt,
                                size: ScreenUtil().setSp(53),
                                color: AppColors.subtext,
                              ),
                              onPressed: () {}),
                          Text(
                            _problem.thumbsUpNum.toString(),
                            style: TextStyle(
                              fontSize: ScreenUtil().setSp(40),
                              color: AppColors.subtext,
                            ),
                          ),
                          SizedBox(width: ScreenUtil().setWidth(30)),
                          IconButton(
                            icon: Icon(
                              MyIcons.remark,
                              size: ScreenUtil().setSp(75),
                              color: AppColors.subtext,
                            ),
                            onPressed: () {},
                          ),
                          Text(
                            _problem.replyNum.toString(),
                            style: TextStyle(
                              fontSize: ScreenUtil().setSp(40),
                              color: AppColors.subtext,
                            ),
                          ),
                        ],
                      ),
                    )
                  ],
                ),
              ],
            ),
          ),
          Divider(
            color: AppColors.subtext,
            height: ScreenUtil().setHeight(12),
          ),
        ],
      ),
    );
  }
}
